/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaz;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Nerea
 */
public class PanelMenu extends javax.swing.JPanel {

	// Variables declaration - do not modify
    private javax.swing.JButton bSalir;
    private javax.swing.JButton bestadoGPS;
    private javax.swing.JButton bestadoSensor;
    private javax.swing.JButton bhistoricoMedic;
    private javax.swing.JButton blistaSensores;
    private javax.swing.JButton bsubirFoto;
    private javax.swing.JButton bvalorSensor;
    private PanelInicial panelInicial;
    private PanelListaSensores panelSensores;
    private PanelHistoricoMediciones panelHistorico;
    private PanelModificarSensor panelModSensor;
    // End of variables declaration
    /**
     * Creates new form PanelMenu
     */
    public PanelMenu(PanelInicial pI) {
        
    	panelInicial = pI;
        blistaSensores = new javax.swing.JButton();
        bhistoricoMedic = new javax.swing.JButton();
        bestadoSensor = new javax.swing.JButton();
        bestadoGPS = new javax.swing.JButton();
        bvalorSensor = new javax.swing.JButton();
        bsubirFoto = new javax.swing.JButton();
        bSalir = new javax.swing.JButton();
        panelSensores = new PanelListaSensores(panelInicial, this);
        panelHistorico = new PanelHistoricoMediciones(panelInicial, this);
        panelModSensor = new PanelModificarSensor(panelInicial, this);

        setLayout(null);

        blistaSensores.setText("Lista sensores");
        blistaSensores.addMouseListener(new MouseListener() {
			public void mouseClicked(MouseEvent evt) {
				listaSensores(evt);
			}

			public void mouseEntered(MouseEvent arg0) {

			}

			public void mouseExited(MouseEvent arg0) {

			}

			public void mousePressed(MouseEvent arg0) {	   }

			public void mouseReleased(MouseEvent arg0) {	}
		});
        add(blistaSensores);
        blistaSensores.setBounds(260, 80, 210, 38);

        bhistoricoMedic.setText("Historico mediciones");
        bhistoricoMedic.addMouseListener(new MouseListener() {
			public void mouseClicked(MouseEvent evt) {
				historico(evt);
			}

			public void mouseEntered(MouseEvent arg0) {

			}

			public void mouseExited(MouseEvent arg0) {

			}

			public void mousePressed(MouseEvent arg0) {	   }

			public void mouseReleased(MouseEvent arg0) {	}
		});
        add(bhistoricoMedic);
        bhistoricoMedic.setBounds(260, 150, 210, 37);

        bestadoSensor.setText("Modificar estado sensor");
        bestadoSensor.addMouseListener(new MouseListener() {
			public void mouseClicked(MouseEvent evt) {
				modSensor(evt);
			}

			public void mouseEntered(MouseEvent arg0) {

			}

			public void mouseExited(MouseEvent arg0) {

			}

			public void mousePressed(MouseEvent arg0) {	   }

			public void mouseReleased(MouseEvent arg0) {	}
		});
        add(bestadoSensor);
        bestadoSensor.setBounds(260, 230, 210, 36);

        bestadoGPS.setText("Mdificar estado GPS");
        add(bestadoGPS);
        bestadoGPS.setBounds(260, 300, 210, 33);

        bvalorSensor.setText("Valor actual sensor");
        add(bvalorSensor);
        bvalorSensor.setBounds(260, 370, 210, 36);

        bsubirFoto.setText("Subir foto");
        add(bsubirFoto);
        bsubirFoto.setBounds(260, 440, 210, 35);

        bSalir.setText("Salir");
        bSalir.addMouseListener(new MouseListener() {
			public void mouseClicked(MouseEvent evt) {
				salir(evt);
			}

			public void mouseEntered(MouseEvent arg0) {

			}

			public void mouseExited(MouseEvent arg0) {

			}

			public void mousePressed(MouseEvent arg0) {	   }

			public void mouseReleased(MouseEvent arg0) {	}
		});
        add(bSalir);
        bSalir.setBounds(650, 520, 90, 40);
    }// </editor-fold>
        
    private void listaSensores(MouseEvent evt) {
		this.setVisible(false);
		panelInicial.ventana.getContentPane().add(panelSensores, 0);
		panelSensores.setVisible(true);
	}
    
    private void historico(MouseEvent evt) {
		this.setVisible(false);
		panelInicial.ventana.getContentPane().add(panelHistorico, 0);
		panelHistorico.setVisible(true);
	}
    
    private void modSensor(MouseEvent evt) {
		this.setVisible(false);
		panelInicial.ventana.getContentPane().add(panelModSensor, 0);
		panelModSensor.setVisible(true);
	}
    
    private void salir(MouseEvent evt) {
		this.setVisible(false);
		panelInicial.ventana.dispose();
	}
}
